<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
    <title>首页APP2</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style>
        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background-color: #f8f9fa;
            margin: 0;
            padding: 0;
        }
        .header {
            background-color: #343a40;
            color: white;
            padding: 1rem 2rem;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        .container {
            max-width: 800px;
            margin: 2rem auto;
            padding: 0 1rem;
        }
        .card {
            background: white;
            border-radius: 8px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            padding: 2rem;
            margin-bottom: 2rem;
        }
        h1 {
            color: #343a40;
            margin-top: 0;
        }
        .btn {
            display: inline-block;
            padding: 0.75rem 1.5rem;
            background-color: #007bff;
            color: white;
            text-decoration: none;
            border-radius: 4px;
            font-weight: 500;
            transition: background-color 0.3s;
        }
        .btn:hover {
            background-color: #0069d9;
        }
        .btn-logout {
            background-color: #dc3545;
        }
        .btn-logout:hover {
            background-color: #c82333;
        }
        .user-info {
            background-color: #e9ecef;
            padding: 1rem;
            border-radius: 4px;
            margin-top: 1.5rem;
        }
        .app-name {
            font-size: 1.25rem;
            font-weight: 600;
        }
    </style>
</head>
<body>
<div class="header">
    <div class="app-name" th:text="${@environment.getProperty('spring.application.name')}">Client App</div>
    <div th:if="${userName}">
        <a href="/logout" class="btn btn-logout">退出登录</a>
    </div>
</div>

<div class="container">
    <div class="card">
        <h1>欢迎使用单点登录系统</h1>
        <p>这是一个使用 Spring Authorization Server 实现的 OAuth2 单点登录示例。</p>

        <div th:if="${userName}">
            <div class="user-info">
                <p>已登录用户: <span th:text="${userName}">用户名</span></p>
                <p>当前应用: <span th:text="${@environment.getProperty('spring.application.name')}">应用名称</span></p>
            </div>
            <a th:href="@{/secured}" class="btn">访问受保护页面</a>
        </div>

        <div th:unless="${#authorities}">
            <p>您尚未登录，请点击下方按钮登录:</p>
            <a th:href="@{/secured}" class="btn">登录系统</a>
        </div>
    </div>

    <div class="card">
        <h2>其他应用</h2>
        <p>尝试访问其他客户端应用:</p>
        <div style="display: flex; gap: 1rem; margin-top: 1rem;">
            <a href="http://localhost:8081" class="btn">客户端应用 1</a>
            <a href="http://localhost:8082" class="btn">客户端应用 2</a>
        </div>
    </div>
</div>
</body>
</html>
